package com.ja.openchat.views;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.widget.TextView;

import com.google.gson.JsonObject;
import com.ja.openchat.R;
import com.ja.openchat.ui.contact.OnContactChatInfoListener;
import com.lxj.xpopup.util.XPopupUtils;
import com.zy.openchat.core.manager.TelegramManager;
import com.zy.openchat.core.manager.TgResponse;
import com.zy.openchat.core.manager.TgResultBlock;
import com.zy.openchat.core.model.call.CallManager;
import com.zy.openchat.core.model.config.AppConfigInfo;
import com.zy.openchat.core.model.message.ChatInfo;
import com.zy.openchat.core.model.user.OrgUserInfo;
import com.zy.openchat.core.model.user.UserFullInfo;
import com.zy.openchat.core.model.user.UserInfo;

import java.util.Map;

import androidx.annotation.NonNull;
import me.goldze.mvvmhabit.utils.ToastUtils;

public class ChatUserVideoMenuDialog extends BaseBottomDialog{

    private final UserInfo user;
    private final OnItemClickListner listner;
    private boolean toShowInvidePath;//邀请来源
//    private boolean blockContact;//是否显示用户账号

    private UserFullInfo userFullInfo;




    public ChatUserVideoMenuDialog(@NonNull Context context, UserInfo user, OnItemClickListner listner) {
        super(context);
        this.user = user;
        this.listner = listner;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_chat_user_video_menu_view;
    }


    @Override
    protected void onCreate() {
        super.onCreate();

        findViewById(R.id.tv_cancel).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        findViewById(R.id.voice_call_btn).setOnClickListener(v -> {
            //语音通话
            if(!canSendMsg()){
                ToastUtils.showShort(getContext().getString(R.string.other_not_friend_first_add));
                return;
            }
            if (user != null) {
                CallManager.startC2CNewCall((Activity) getContext(), user,false);
            }
        });

        findViewById(R.id.video_call_btn_btn).setOnClickListener(v -> {
            //视频通话
            if(!canSendMsg()){
                ToastUtils.showShort(getContext().getString(R.string.other_not_friend_first_add));
                return;
            }
            if (user != null) {
                CallManager.startC2CNewCall((Activity) getContext(), user,true);
            }
        });

    }

    private boolean canSendMsg() {
        if (user != null) {
            return user.canSendMsg();
        }
        return false;
    }

    @Override
    protected void onShow() {
        super.onShow();
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
    }

    @Override
    protected int getMaxHeight() {
        return (int) (XPopupUtils.getAppHeight(getContext()) * 0.98f);
    }


    public interface OnItemClickListner {
        void clickPostion(int position,ChatInfo postion);
    }

}
